local shapeshift_on_mouseover, petbar_on_mouseover 

shapeshift_on_mouseover = 1

 ---------------------------------------------------
  -- CREATE ALL THE HOLDER FRAMES
  ---------------------------------------------------

  frame_positions = {
    [9]  =  { a = "RIGHT",         x = -120,    y = 163 },  --petbar
    [10] =  { a = "TOP",         x = 0,    y = 0 },  --shapeshift
    [11] =  { a = "BOTTOM",         x = 330,    y = 11 },  --my own vehicle exit button
  }
 
  -- Frame to hold the ActionBar1 and the BonusActionBar
  local fbar1 = CreateFrame("Frame","rABS_Bar1Holder",UIParent)
    fbar1:SetWidth(518)
    fbar1:SetHeight(58)
    fbar1:SetPoint("BOTTOM",-92,9)  
	fbar1:Show()
  
  -- Frame to hold the MultibarLeft
  local fbar2 = CreateFrame("Frame","rABS_Bar2Holder",UIParent)
    fbar2:SetWidth(58)
    fbar2:SetHeight(58)
    fbar2:SetPoint("BOTTOM",134,9)  
	fbar2:Show()

  -- Frame to hold the MultibarRight
  local fbar3 = CreateFrame("Frame","rABS_Bar3Holder",UIParent)
  fbar3:SetWidth(58)
  fbar3:SetHeight(58)
  fbar3:SetPoint("BOTTOM",-323,61)
  fbar3:Show() 
  
  -- Frame to hold the right bars
  local fbar45 = CreateFrame("Frame","rABS_Bar45Holder",UIParent)
  fbar45:SetWidth(58) -- size the width here
  fbar45:SetHeight(58) -- size the height here
  fbar45:SetPoint("BOTTOMRIGHT",-447,28) 
  
  -- Frame to hold the pet bars  
  local fpet = CreateFrame("Frame","rABS_PetBarHolder",UIParent)
  fpet:SetWidth(53) -- size the width here
  fpet:SetHeight(53) -- size the height here
  fpet:SetPoint(frame_positions[9].a,frame_positions[9].x,frame_positions[9].y)
  
  
  -- Frame to hold the shapeshift bars  
  local fshift = CreateFrame("Frame","rABS_ShapeShiftHolder",UIParent)
  fshift:SetWidth(260) -- size the width here
  fshift:SetHeight(50) -- size the height here
  fshift:SetPoint(frame_positions[10].a,frame_positions[10].x,frame_positions[10].y) 
  
  ---------------------------------------------------
  -- CREATE MY OWN VEHICLE EXIT BUTTON
  ---------------------------------------------------
  
  local fveb = CreateFrame("Frame","rABS_VEBHolder",UIParent)
  fveb:SetWidth(40) -- size the width here
  fveb:SetHeight(40) -- size the height here
  fveb:SetPoint(frame_positions[11].a,frame_positions[11].x,frame_positions[11].y) 
  
  local veb = CreateFrame("BUTTON", "rABS_VehicleExitButton", fveb, "SecureActionButtonTemplate");
  veb:SetWidth(30)
  veb:SetHeight(30)
  veb:SetPoint("CENTER",0,0)
  veb:RegisterForClicks("AnyUp")
  veb:SetNormalTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up")
  veb:SetPushedTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Down")
  veb:SetHighlightTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Down")
  veb:SetScript("OnClick", function(self) VehicleExit() end)
  veb:RegisterEvent("UNIT_ENTERING_VEHICLE")
  veb:RegisterEvent("UNIT_ENTERED_VEHICLE")
  veb:RegisterEvent("UNIT_EXITING_VEHICLE")
  veb:RegisterEvent("UNIT_EXITED_VEHICLE")
  veb:SetScript("OnEvent", function(self,event,...)
    local arg1 = ...;
    if(((event=="UNIT_ENTERING_VEHICLE") or (event=="UNIT_ENTERED_VEHICLE")) and arg1 == "player") then
      veb:SetAlpha(1)
    elseif(((event=="UNIT_EXITING_VEHICLE") or (event=="UNIT_EXITED_VEHICLE")) and arg1 == "player") then
      veb:SetAlpha(0)
    end
  end)  
  veb:SetAlpha(0)
 
  ---------------------------------------------------
  -- MOVE STUFF INTO POSITION
  ---------------------------------------------------
  local i,f
    
  --bar1
  for i=1, 12 do
    _G["ActionButton"..i]:SetParent(fbar1);
  end
  ActionButton1:ClearAllPoints()
  ActionButton1:SetPoint("BOTTOMLEFT",fbar1,"BOTTOMLEFT",10,10);  
  for i=2, 12 do
    local b = _G["ActionButton"..i]
	local b2 = _G["ActionButton"..i-1]
	b:ClearAllPoints()
	b:SetPoint("LEFT",b2,"RIGHT",2,0)
  end 

  --bonus bar  
  BonusActionBarFrame:SetParent(fbar1)
  BonusActionBarFrame:SetWidth(0.01)
  BonusActionBarTexture0:Hide()
  BonusActionBarTexture1:Hide()
  BonusActionButton1:ClearAllPoints()
  BonusActionButton1:SetPoint("BOTTOMLEFT", fbar1, "BOTTOMLEFT", 10, 10);
for i=2, 12 do
  local b = _G["BonusActionButton"..i]
  local b2 = _G["BonusActionButton"..i-1]
  b:ClearAllPoints()
  b:SetPoint("LEFT",b2,"RIGHT",2,0)
end
  
  --bar2
  MultiBarBottomLeft:SetParent(fbar2)
  MultiBarBottomLeftButton1:ClearAllPoints()
  MultiBarBottomLeftButton1:SetPoint("BOTTOMLEFT", fbar2, "BOTTOMLEFT", 10, 10);
  for i=2, 6 do
    local b = _G["MultiBarBottomLeftButton"..i]
	local b2 = _G["MultiBarBottomLeftButton"..i-1]
	b:ClearAllPoints()
	b:SetPoint("LEFT",b2,"RIGHT",2,0)
  end 
  
  MultiBarBottomLeftButton7:ClearAllPoints()
  MultiBarBottomLeftButton7:SetPoint("BOTTOMLEFT",MultiBarBottomLeftButton1, "TOPLEFT", -22, 6);
  MultiBarBottomLeftButton7:SetScale(0.75/0.89)
  for i=8, 12 do
    local b = _G["MultiBarBottomLeftButton"..i]
	local b2 = _G["MultiBarBottomLeftButton"..i-1]
	b:ClearAllPoints()
	b:SetPoint("LEFT",b2,"RIGHT",2,0)
	b:SetScale(0.75/0.89)
  end  
  
  --bar3
  MultiBarBottomRight:SetParent(fbar3)
  MultiBarBottomRightButton1:ClearAllPoints()
  MultiBarBottomRightButton1:SetPoint("BOTTOMLEFT", fbar3, "BOTTOMLEFT", 10, 10);
  for i=2, 12 do
    local b = _G["MultiBarBottomRightButton"..i]
	local b2 = _G["MultiBarBottomRightButton"..i-1]
	b:ClearAllPoints()
	b:SetPoint("LEFT",b2,"RIGHT",2,0)
  end
  
  --shift
  ShapeshiftBarFrame:SetParent(fshift)
  ShapeshiftBarFrame:SetWidth(0.01)
  ShapeshiftButton1:ClearAllPoints()
  ShapeshiftButton1:SetPoint("BOTTOMLEFT",fshift,"BOTTOMLEFT",10,10)
  local function rABS_MoveShapeshift()
    ShapeshiftButton1:SetPoint("BOTTOMLEFT",fshift,"BOTTOMLEFT",10,10)
  end
  for i=2, 10 do
    local b = _G["ShapeshiftButton"..i]
	local b2 = _G["ShapeshiftButton"..i-1]
	b:ClearAllPoints()
	b:SetPoint("LEFT",b2,"RIGHT",stancepadding,0)
  end 
  hooksecurefunc("ShapeshiftBar_Update", rABS_MoveShapeshift);  
  
  --possess bar
  PossessBarFrame:SetParent(fshift)
  PossessButton1:ClearAllPoints()
  PossessButton1:SetPoint("BOTTOMLEFT", fshift, "BOTTOMLEFT", 10, 10);
  
  --totem bar
  if select(2, UnitClass("Player")) == "SHAMAN" then
    MultiCastSummonSpellButton:SetParent(fshift)
    for i=1, 4 do
      _G["MultiCastSlotButton"..i]:SetParent(fshift)
    end
    for i=1, 3 do
      local b = _G["MultiCastActionPage"..i]
      b:SetParent(fshift)
      b:SetWidth(0.01)
    end
    MultiCastFlyoutFrame:SetParent(fshift)
    MultiCastRecallSpellButton:SetParent(fshift)

    MultiCastSummonSpellButton:ClearAllPoints()
    MultiCastSummonSpellButton:SetPoint("BOTTOMLEFT",fshift,"BOTTOMLEFT",10,10)

    MultiCastSlotButton1:ClearAllPoints()
    MultiCastSlotButton1:SetPoint("LEFT",MultiCastSummonSpellButton,"RIGHT",stancepadding,0)
    for i=2, 4 do
      local b = _G["MultiCastSlotButton"..i]
      local b2 = _G["MultiCastSlotButton"..i-1]
      b:ClearAllPoints()
      b:SetPoint("LEFT",b2,"RIGHT",stancepadding,0)
    end

    for i=1, 12 do
      local b = _G["MultiCastActionButton"..i], b2
      b:ClearAllPoints()
      if i % 4 == 1 then
        b:SetPoint("LEFT",MultiCastSummonSpellButton,"RIGHT",stancepadding,0)
      else
        b2 = _G["MultiCastActionButton"..i-1]
        b:SetPoint("LEFT",b2,"RIGHT",stancepadding,0)
      end
    end

    MultiCastRecallSpellButton:ClearAllPoints()
    MultiCastRecallSpellButton:SetPoint("LEFT",MultiCastActionButton4,"RIGHT",stancepadding,0)

    local dummy = function() return end
    for i=1, 4 do
      local b = _G["MultiCastSlotButton"..i]
      b.SetParent = dummy
      b.SetPoint = dummy
    end
    MultiCastRecallSpellButton.SetParent = dummy
    MultiCastRecallSpellButton.SetPoint = dummy
  end
  
  --pet
  PetActionBarFrame:SetParent(fpet)
  PetActionBarFrame:SetWidth(0.01)
  PetActionButton1:ClearAllPoints()
  PetActionButton1:SetPoint("BOTTOMLEFT",fpet,"BOTTOMLEFT",10,10)
  for i=2, 10 do
    local b = _G["PetActionButton"..i]
	local b2 = _G["PetActionButton"..i-1]
	b:ClearAllPoints()
	b:SetPoint("TOP",b2,"BOTTOM",0,petpadding)
  end 

  --right bars
  MultiBarRight:SetParent(fbar45);
  MultiBarLeft:SetParent(fbar45);
  MultiBarRight:ClearAllPoints()
  MultiBarRight:SetPoint("TOPRIGHT",-10,-10)
  MultiBarLeft:ClearAllPoints()
  MultiBarLeft:SetPoint("TOPRIGHT",-10,30)
  for i=2, 12 do
    local b = _G["MultiBarRightButton"..i]
	local b2 = _G["MultiBarRightButton"..i-1]
	b:ClearAllPoints()
	b:SetPoint("Left",b2,"RIGHT",4,0)
  end 
  for i=2, 12 do
    local b = _G["MultiBarLeftButton"..i]
	local b2 = _G["MultiBarLeftButton"..i-1]
	b:ClearAllPoints()
	b:SetPoint("LEFT",b2,"RIGHT",4,0)
  end 
  
  -- hide actionbuttons when the bonusbar is visible (rogue stealth and such)
  local function rABS_showhideactionbuttons(alpha)
    local f = "ActionButton"
    for i=1, 12 do
      _G[f..i]:SetAlpha(alpha)
    end
  end
  BonusActionBarFrame:HookScript("OnShow", function(self) rABS_showhideactionbuttons(0) end)
  BonusActionBarFrame:HookScript("OnHide", function(self) rABS_showhideactionbuttons(1) end)
  if BonusActionBarFrame:IsShown() then
    rABS_showhideactionbuttons(0)
  end

  local function rABS_showhideshapeshift(alpha)
    for i=1, NUM_SHAPESHIFT_SLOTS do
      local pb = _G["ShapeshiftButton"..i]
      pb:SetAlpha(alpha)
    end;
  end
  
  ---------------------------------------------------
  -- MAKE THE DEFAULT BARS UNVISIBLE
  ---------------------------------------------------
  
  local FramesToHide = {
    MainMenuBar,
    VehicleMenuBar,
  }  
  
  local function rABS_HideDefaultFrames()
    for _, f in pairs(FramesToHide) do
      f:SetScale(0.001)
      f:SetAlpha(0)
    end
  end  
  rABS_HideDefaultFrames(); 

  ---------------------------------------------------
  -- SCALING
  ---------------------------------------------------
  fbar1:SetScale(0.89)
  fbar2:SetScale(0.89)
  fbar3:SetScale(0.75)
  fbar45:SetScale(0.825)
  
  --fshift:SetScale(0.001)
  --fshift:SetAlpha(0)
   
  --fpet:SetScale(0.001)
  --fpet:SetAlpha(0)

  if shapeshift_on_mouseover == 1 then
    fshift:EnableMouse(true)
    fshift:SetScript("OnEnter", function(self) rABS_showhideshapeshift(1) end)
    fshift:SetScript("OnLeave", function(self) rABS_showhideshapeshift(0) end)  
    for i=1, NUM_SHAPESHIFT_SLOTS do
      local pb = _G["ShapeshiftButton"..i]
      pb:SetAlpha(0)
      pb:HookScript("OnEnter", function(self) rABS_showhideshapeshift(1) end)
      pb:HookScript("OnLeave", function(self) rABS_showhideshapeshift(0) end)
    end
  end
  
  function fbar45_OnEvent(this, event, key)
	if ( event == "PLAYER_REGEN_ENABLED" ) or ( event == "PLAYER_ENTERING_WORLD" ) or (event == "MODIFIER_STATE_CHANGED") then
		ChatFrame3:Show();
		if(key == "LSHIFT" or key == "RSHIFT") and not InCombatLockdown() then
			fbar45:Show()
		elseif not InCombatLockdown() then
			fbar45:Hide()
		elseif InCombatLockdown() then
			ChatFrame3:Hide();
		end
	elseif ( event == "PLAYER_REGEN_DISABLED" ) then
		ChatFrame3:Hide();
		fbar45:Show();
	end
  end
  
	fbar45:RegisterEvent("PLAYER_REGEN_ENABLED");
	fbar45:RegisterEvent("PLAYER_REGEN_DISABLED");
	fbar45:RegisterEvent("PLAYER_ENTERING_WORLD");
	fbar45:RegisterEvent("MODIFIER_STATE_CHANGED");
	fbar45:SetScript("OnEvent", fbar45_OnEvent);
  